package annotation;

import annotation.bean.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        //require();
        //autowired();
        //autowierd2();
        //qualifier();
        // preDestroyAndPostConstruct();
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final Groups2 groups2 = (Groups2) context.getBean("groups2");
        System.out.println(groups2);
    }

    private static void preDestroyAndPostConstruct() {
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final People people = (People) context.getBean("people");
        System.out.println(people);
        context.registerShutdownHook();
    }

    private static void qualifier() {
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final Groups group = (Groups) context.getBean("groups");
        System.out.println(group);
    }

    private static void autowierd2() {
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final Group2 group = (Group2) context.getBean("group2");
        System.out.println(group);
    }

    private static void autowired() {
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final Group group = (Group) context.getBean("group1");
        System.out.println(group);
    }

    private static void annotition(String name) {
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotation\\xml\\beans.xml");
        final People people = (People) context.getBean(name);
        System.out.println(people);
    }

    private static void require() {
        annotition("people");
    }
}
